<link href="<?php echo base_url(); ?>public/admin/css/threads.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<?php echo base_url(); ?>public/admin/assets/js/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>public/admin/script/jquery-ui.js"></script>
<div id="threads" class="">	
	<span class="ng-scope">
	<p class="heading" style="text-align: center; font-weight: bold">BÌNH LUẬN</p>
		<table class="data">
			<tbody>
				<tr class="header">
					<th width="28%">Bài đăng</th>
					<th width="10%">Người bình luận</th>
					<th width="35%">Nội dung</th>
					<th width="10%"><a href="<?php echo $backend;?><?php if($sort_by_status == ""){ echo "Status_asc"; } else { echo $sort_by_status; } ?>">Trạng thái</a></th>
					<th width="15%"></th>
				</tr>						
            	<tbody>
            		<?php 
            			$page = 1;
						$perPage = 10;

						if (!empty($_GET['page'])) {
						    $page = $_GET['page']; // using the get method
						} else {
						    $page = 1; // if we don't have a page number then assume we are on the first page
						}

						$length = count($coms);
						$pages = ceil($length / $perPage);
						$start  = ceil(($page - 1) * $perPage);

						$comments = array_slice($coms, $start, $perPage);

						echo "<p style='text-align:center;'>";

						// first/prev pagination hyperlinks
						if ($page == 1) {
						   // echo " Đầu Trước ";
						} else {
						   echo " <a href='?page=1'>Đầu</a> ";
						   $prevpage = $page-1;
						   echo " <a href='?page=$prevpage'>Trước</a> ";
						}

						// Display current page or pages
						echo " ( Trang $page trên $pages ) ";

						// next/last pagination hyperlinks
						if ($page == $pages) {
						   // echo " Tiếp Cuối ";
						} else {
						   $nextpage = $page+1;
						   echo " <a href='?page=$nextpage'>Tiếp</a> ";
						   echo " <a href='?page=$pages'>Cuối</a> ";
						}

						echo "</p>";
            		 ?>
        			<?php foreach ($comments as $a):?>
        			<tr class="data odd-false selected-false" style="border-bottom: dashed thin #cccccc">
        				<td>
							<?php 
        						foreach($news as $n){
		                            if($n['Id'] == $a['PlaceId']){
		                                echo $n['Title'];
		                            }
                            	}
                            ?>
        				</td>
        				<td>
							<?php 
        						foreach($user as $u){
		                            if($u['UserId'] == $a['UserId']){
		                                echo $u['UserName'];
		                            }
                            	}
                            ?>
        				</td>
        				<td><?php echo $a['Content'];?></td>
        				<td>
        					<?php 
		        				$status = "";
								if ($a['status'] == "true") {
									$status = "Hiện";
								}
								else{
									$status = "Ẩn";
								}
								echo $status;
							?>
						</td>	
						<div style="text-align: right;">
        					<td style="border-left: solid thin #cccccc">
								<div class="btn-group">
									<?php 
				        				$status = "";
										if ($a['status'] == "true") {
											echo "<a class='btn btn-primary btn-small' href='" .$backend. "disable_comment/" .$a['Id']. "'>";
											echo "<span><i class='icon-remove'></i>&nbsp;&nbsp;Ẩn&nbsp;&nbsp;&nbsp;</span></a>";
										}
										else{
											echo "<a class='btn btn-primary btn-small' href='" .$backend. "enable_comment/" .$a['Id']. "'>";
											echo "<span><i class='icon-ok'></i>&nbsp;Hiện&nbsp;</span></a>";
										}
										echo $status;
									?>
								   	<a class="btn btn-inverse btn-small dropdown-toggle" data-toggle="dropdown" href=""><span class="caret"></span></a>
								  	<ul class="dropdown-menu">
									    <li><a href="<?php echo $backend.'delete_comment/'.$a['Id']?>" onclick="return checkMe()"><i class="icon-trash"></i> Xóa</a></li>
							    	</ul>
								</div>	
							</td>
						</div>				
				    </tr>

					<?php endforeach; ?>
				</tbody>
			</tbody>
		</table>
	</span> 
	<span class="ng-scope">
	</span>
</div>
<script>

function checkMe() {
    if (confirm("Bạn có chắc xóa không?")) {
        return true;
    } else {
        return false;
    }
}
</script>